home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-22 | 1.5 KB | 46 lines | [TEXT/MPS ] |
- *
- * ALLOCA.PMA Stack heap storage allocator.
- *
- * Date Programmer History
- * --------- -------------- --------------------------------------------------
- * 880805 P. Eriksson Initial coding.
- *
-
-
- SEGR
- SYML
- RLIT
-
- ENT G$ALLOCA,ECB$$
-
- P$ALLOCA EQU *
- L 2,XB%+0 - Fetch 'size' argument
- BRLE 2,FAIL - Terminate if 'size' <= 0
- IR1 2 - Compensate for odd bytes
- SR1 2 - Convert to number of shorts
- BHNE 2,FAIL - Fail if high word != 0
- IRH 2 - Put length into halfword
- CH% 2,=65530 - Compare with maximum limit
- BMGT FAIL - Fail if block too big
- IRH 2 - Put length into fullword
- L 1,2 - Save length for later usage
- STEX 2 - Allocate stack storage
-
- L 3,2 - Save block pointer for later
-
- ZNEXT ZMH R2% - Clear halfword
- IR1 2 - Point at next
- DR1 1 - Decrement length
- BRGT 1,ZNEXT - Loop until length == 0
-
- L 2,3 - Get block pointer back
- JMP R0% - Return to caller
-
- FAIL CR 2 - Put a NULL pointer into R2
- JMP R0% - Return to caller
-
- LINK
- ECB$$ ECB P$ALLOCA,,,-1
-
- END
-